from rest_framework import serializers
from system_config.models import Credential, Notify,BlacklistIP

class CredentialSerializer(serializers.ModelSerializer):

    create_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
    update_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)

    class Meta:
        model = Credential
        fields = "__all__"
        read_only_fields = ("id",)

class NotifySerializer(serializers.ModelSerializer):
    """
    消息通知序列化类
    """
    create_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)
    class Meta:
        model = Notify
        fields = "__all__"
        read_only_fields = ('id',)


class BlacklistSerializer(serializers.ModelSerializer):

    create_time = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S", required=False, read_only=True)

    class Meta:
        model = BlacklistIP
        fields = "__all__"
        read_only_fields = ("id",)